package com.handc.springcloud.service;


import com.handc.springcloud.pojo.Student;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

//服务降级
@Component
public class StudentClientServiceFallbackFactory implements FallbackFactory {
    public Object create(Throwable throwable) {
        return new StudentClientService() {
            public Student queryById(Long id) {
                return new Student()
                        .setId(id)
                        .setName("id==>"+id+"没有对应的信息,客户端提供降级信息,这个服务已经关闭")
                        .setDb_name("没有数据");
            }

            public List<Student> queryAll() {
                return null;
            }

            public boolean addStudent(Student student) {
                return false;
            }
        };
    }
}
